/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.utrans.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Gamboa
 */
@Entity
@Table(name = "avance_tarjeta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AvanceTarjeta.findAll", query = "SELECT a FROM AvanceTarjeta a"),
    @NamedQuery(name = "AvanceTarjeta.findByCodigoPasajero", query = "SELECT a FROM AvanceTarjeta a WHERE a.avanceTarjetaPK.codigoPasajero = :codigoPasajero"),
    @NamedQuery(name = "AvanceTarjeta.findByCodigoTarjeta", query = "SELECT a FROM AvanceTarjeta a WHERE a.avanceTarjetaPK.codigoTarjeta = :codigoTarjeta"),
    @NamedQuery(name = "AvanceTarjeta.findByFechaHoraAvanceTarjeta", query = "SELECT a FROM AvanceTarjeta a WHERE a.avanceTarjetaPK.fechaHoraAvanceTarjeta = :fechaHoraAvanceTarjeta"),
    @NamedQuery(name = "AvanceTarjeta.findByValorAvance", query = "SELECT a FROM AvanceTarjeta a WHERE a.valorAvance = :valorAvance")})
public class AvanceTarjeta implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AvanceTarjetaPK avanceTarjetaPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "valor_avance")
    private BigDecimal valorAvance;
    @JoinColumn(name = "codigo_tarjeta", referencedColumnName = "codigo_tarjeta", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tarjeta tarjeta;
    @JoinColumn(name = "codigo_pasajero", referencedColumnName = "codigo_pasajero", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Pasajero pasajero;

    public AvanceTarjeta() {
    }

    public AvanceTarjeta(AvanceTarjetaPK avanceTarjetaPK) {
        this.avanceTarjetaPK = avanceTarjetaPK;
    }

    public AvanceTarjeta(AvanceTarjetaPK avanceTarjetaPK, BigDecimal valorAvance) {
        this.avanceTarjetaPK = avanceTarjetaPK;
        this.valorAvance = valorAvance;
    }

    public AvanceTarjeta(int codigoPasajero, int codigoTarjeta, Date fechaHoraAvanceTarjeta) {
        this.avanceTarjetaPK = new AvanceTarjetaPK(codigoPasajero, codigoTarjeta, fechaHoraAvanceTarjeta);
    }

    public AvanceTarjetaPK getAvanceTarjetaPK() {
        return avanceTarjetaPK;
    }

    public void setAvanceTarjetaPK(AvanceTarjetaPK avanceTarjetaPK) {
        this.avanceTarjetaPK = avanceTarjetaPK;
    }

    public BigDecimal getValorAvance() {
        return valorAvance;
    }

    public void setValorAvance(BigDecimal valorAvance) {
        this.valorAvance = valorAvance;
    }

    public Tarjeta getTarjeta() {
        return tarjeta;
    }

    public void setTarjeta(Tarjeta tarjeta) {
        this.tarjeta = tarjeta;
    }

    public Pasajero getPasajero() {
        return pasajero;
    }

    public void setPasajero(Pasajero pasajero) {
        this.pasajero = pasajero;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (avanceTarjetaPK != null ? avanceTarjetaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AvanceTarjeta)) {
            return false;
        }
        AvanceTarjeta other = (AvanceTarjeta) object;
        if ((this.avanceTarjetaPK == null && other.avanceTarjetaPK != null) || (this.avanceTarjetaPK != null && !this.avanceTarjetaPK.equals(other.avanceTarjetaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.utrans.entity.AvanceTarjeta[ avanceTarjetaPK=" + avanceTarjetaPK + " ]";
    }
    
}
